﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChangeOperate.aspx.cs" Inherits="ZX.WebApp.Crm.ChangeOperate" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/event-delegate/event-delegate-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/resize/resize-min.js"></script>   
    <script src="../../Scripts/jquery-1.6.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery.json-2.2.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    <script src="../../Scripts/CombinButton.js" type="text/javascript"></script>
    <script src="../../Scripts/extend.validate.js" type="text/javascript"></script>
    <link href="../../Styles/base.css" rel="stylesheet" type="text/css" />
    <link href="../../Styles/extendTable.css" rel="stylesheet" type="text/css" />
</head>
<body class="yui-skin-sam" onkeydown="PreventBSK()"> 
    <form id="form1" runat="server"> 
    <div class="noprint">
        <div id="content">
            <h3>客户操作</h3>
            <table class="table1">
                <tr>
                    <th>
                        <span>客户操作</span>
                    </th>
                    <td>
                        <input type="hidden" id="Customer" />
                        <button id="btnCustomer" name="8" runat="server" type="button" class="btnCheck" style="width: 110px; height:30px;">
                            公海 -> 客户信息</button>&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="hidden" id="CustomerInfo" />
                        <button id="btnCustomerInfo" name="9" runat="server" type="button" class="btnCheck" style="width: 110px; height:30px;">
                            客户信息 -> 公海</button>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            信息选择</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    </form>
</body>
<script type="text/javascript">
    var _CustomerId = "", _State = "0";
    /* 对应的方法和ID*/
    var _fn, _id;
    function ShowDialog(fn, id, src) {
        _fn = fn;
        _id = id;
        document.getElementById("EditUIWindow1").src = src;
        SetMaxDWH(YAHOO.example.container.dialog1);        
        YAHOO.example.container.dialog1.show();
    }
    function ShowDialog2(fn, id) {
        _fn = fn;
        _id = id;
        SetMaxDWH(YAHOO.example.container.dialog1);
        YAHOO.example.container.dialog1.show();
    }
    function checkSure() {
        if ($("#txtPM").val() == "") {
            alert("您需选择用户");
            return false;
        }
        if (!confirm("您确定切换到当前用户吗?")) {
            return false;
        }
    }
    YAHOO.namespace("example.container");
    YAHOO.util.Event.onDOMReady(function () {
        var handleSubmit = function () {
            var editwindow = document.getElementById("EditUIWindow1");
            if (editwindow) {
                if (_id == "btnPM") {
                    _State = "0";
                    editwindow.contentWindow.ChooseInfo();
                } else {
                    SetCustomer();
                }
            }
            if (_State != "") {
                YAHOO.example.container.dialog1.hide();
            }
        };
        var handleCancel = function () {
            this.cancel();
        };
        var handleSuccess = function (o) {
            var response = o.responseText;
            response = response.split("<!")[0];
            document.getElementById("resp").innerHTML = response;
        };
        var handleFailure = function (o) {
            alert("Submission failed: " + o.status);
        };
        YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1",
					        { width: "650px",
					            height: "450px",
					            fixedcenter: true,
					            visible: false,
					            draggable: true,
					            close: true,
                                modal:true,
					            autofillheight: "body",
					            constraintoviewport: true,
					            buttons: [{ text: "确定", handler: handleSubmit, isDefault: true },
								        { text: "取消", handler: handleCancel}]
					        });
        YAHOO.example.container.dialog1.callback = { success: handleSuccess, failure: handleFailure };
        YAHOO.example.container.dialog1.render();
        //拖动大小1
        var resize = new YAHOO.util.Resize("dialog1", {
            handles: ["br"],
            autoRatio: false,
            minWidth: 450,
            minHeight: 300,
            status: false
        });
        resize.on("startResize", function (args) {
            if (this.cfg.getProperty("constraintoviewport")) {
                var D = YAHOO.util.Dom;

                var clientRegion = D.getClientRegion();
                var elRegion = D.getRegion(this.element);

                resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
                resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
            } else {
                resize.set("maxWidth", null);
                resize.set("maxHeight", null);
            }

        }, YAHOO.example.container.dialog1, true);
        resize.on("resize", function (args) {
            var panelHeight = args.height;
            this.cfg.setProperty("height", panelHeight + "px");
        }, YAHOO.example.container.dialog1, true);
        //拖动大小2
        var resize = new YAHOO.util.Resize("dialog2", {
            handles: ["br"],
            autoRatio: false,
            minWidth: 300,
            minHeight: 250,
            status: false
        });
        resize.on("startResize", function (args) {
            if (this.cfg.getProperty("constraintoviewport")) {
                var D = YAHOO.util.Dom;

                var clientRegion = D.getClientRegion();
                var elRegion = D.getRegion(this.element);

                resize.set("maxWidth", clientRegion.right - elRegion.left - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
                resize.set("maxHeight", clientRegion.bottom - elRegion.top - YAHOO.widget.Overlay.VIEWPORT_OFFSET);
            } else {
                resize.set("maxWidth", null);
                resize.set("maxHeight", null);
            }

        }, YAHOO.example.container.dialog2, true);
        resize.on("resize", function (args) {
            var panelHeight = args.height;
            this.cfg.setProperty("height", panelHeight + "px");
        }, YAHOO.example.container.dialog2, true);
    });
    // 设窗口最大化
    var SetMaxDWH = function (dialog) {
        var w = Y.util.Dom.getViewportWidth() - 20;
        var h = Y.util.Dom.getViewportHeight() - 20;
        SetDWH(w, h, dialog);
    }
    // 设置对话框的大小
    var SetDWH = function (width, height, dialog) {
        var elements = YAHOO.util.Dom.getElementsByClassName('bd', 'div')[0];
        var w = [],
            h = [];
        w.push(width);
        h.push(height);
        dialog.configWidth(null, w);
        dialog.configHeight(null, h);
        dialog.render();
        if (elements) {
            dialog.fillHeight(elements);
        }
    }

    //切换客户
    var SetCustomer = function () {
        var vid = _CustomerId; //客户ID
        var vtype = "0";
        if (_CustomerId != "") {
            if (_id == "btnCustomer") {
                vtype = "0";
            } else if (_id == "btnCustomerInfo") {
                vtype = "1";
            }
            if (confirm("您确定切换?")) {
                var SaveUrl = "../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=update&entity=CrmCustomeToCustomerInfo&json=&id=" + vid + "&type=" + vtype;
                YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
                    success: function (res) {
                        try {
                            var str = res.responseText;
                            if (str == "1") {
                                _State = "0";
                                alert("客户操作成功!");
                            } else {
                                _State = "";
                                alert(str);
                                return;
                            }
                        }
                        catch (e) {
                        }
                        finally {
                        }
                    },
                    failure: function (error) {
                        alert("数据错误：" + error.statusText);
                    }
                }, null);
            } else {
                _State = "";
            }
        } else {
            _State = "";
            alert("请选择一行数据!");
        }
    }
</script>
</html>
